// Finds the sum of even-valued terms lower than 4000000 of Fibonacci sequence

#include<stdio.h>

void problem2(){

	int fib_olda = 1; int fib_oldb = 2; // initial terms
	int fib_new = 0; int sum = 2;

	printf("\nFibonacci: %d\nFibonacci: %d", fib_olda, fib_oldb);

	while(fib_new<4000000){

		fib_new = fib_oldb + fib_olda;
		fib_olda = fib_oldb;
		fib_oldb = fib_new;

		printf("\nFibonacci: %d", fib_new);

		if(fib_new%2 == 0){

			sum = sum + fib_new;

		}

	}

	printf("\nSum of even-valued terms = %d", sum);

}
